<template>
	<view class="mainpadding2">
		<view class="mainpadding_top ffffff radius flexbetween">
			<view class="titletext hei_text bold">老师手机号</view>
			<input type="number" placeholder="请输入老师手机号" class="main_size hei_text bold" style="text-align: right;" v-model="mobile">
		</view>
		<view class="mainpadding_top ffffff radius flexbetween" @click="xkshow=true">
			<view class="titletext hei_text bold">学科</view>
			<view class="flexright">
				<input type="text" placeholder="请选择学科" class="main_size hei_text bold" disabled style="text-align: right;" v-model="xkmsg.name">
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>
		</view>
		<view class="mainpadding_top ffffff radius flexbetween">
			<view class="titletext hei_text bold">班级</view>
			<input type="text" placeholder="请输入班级" class="main_size hei_text bold" style="text-align: right;" v-model="classname">
		</view>
		<view class="posibottom mainpadding">
			<view class="submitbtn" @click="submit">提交审核</view>
		</view>
		<u-picker :show="xkshow" :columns="xkcolumns" title="选择学科" keyName="name" @cancel="xkshow=false" @confirm="xkconfirm"></u-picker>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				mobile:"",
				classname:"",
				njInfo:uni.getStorageSync("njInfo"),
				xkshow:false,
				xkcolumns:[],
				xkmsg:{
					id:"",
					name:"",
				},
			}
		},
		onLoad() {
			this.getXkList()
		},
		methods: {
			getXkList() { //获取学科数据
				httpRequest.request('/api/index/getsubject', 'GET', {
					education_grade_id: this.njInfo.id,
					period: this.njInfo.period,
				}).then(res => {
					this.xkcolumns = []
					this.xkcolumns.push(res.data)
				})
			},
			xkconfirm(e){//学科确定
				this.xkmsg.name = e.value[0].name
				this.xkmsg.id = e.value[0].id
				this.xkshow = false
			},
			submit(){
				if(this.mobile==""){
					httpRequest.toast("请输入老师手机号")
					return false
				}
				if(this.xkmsg.id==""){
					httpRequest.toast("请选择学科")
					return false
				}
				if(this.classname==""){
					httpRequest.toast("请输入班级")
					return false
				}
				httpRequest.request('/api/teacher/add_myteacher', 'POST', {
					mobile:this.mobile,
					classname:this.classname,
					education_subject_id:this.xkmsg.id,
				}, false, false, true).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			}
		}
	}
</script>

<style>

</style>
